<!DOCTYPE html>
<html>

<head>
    <meta charset="utf8">
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>

<body>
    <div id="myapp">
        <input v-model="search_text" placeholder="请输入...(长度限度为10)">
    </div>
</body>
<script>
    const app = {
        data() {
            return {
                search_text: ""
            }
        },
        // 对数据进行监听
        watch: {
            search_text(new_value, old_value) {
                if (new_value.length > 10) {
                    alert("文本过长!");
                }
            }
        }
    }
    let instance = Vue.createApp(app).mount("#myapp");
</script>

</html>